#!/usr/bin/env bash
set -x 

go mod vendor
retVal=$?
if [ $retVal -ne 0 ]; then
    exit $retVal
fi

set -e
TMP_DIR=/home/love/tmp
mkdir -p "${TMP_DIR}"/src/gitee.com/lovekernel/tiger/pkg/client
cp -r ./{api,hack,vendor,go.mod,.git} "${TMP_DIR}"/src/gitee.com/lovekernel/tiger

chmod +x "${TMP_DIR}"/src/gitee.com/lovekernel/tiger/vendor/k8s.io/code-generator/generate-internal-groups.sh
echo "tmp_dir: ${TMP_DIR}"

(cd "${TMP_DIR}"/src/gitee.com/lovekernel/tiger; \
    GOPATH=${TMP_DIR} GO111MODULE=off /bin/bash vendor/k8s.io/code-generator/generate-groups.sh client,deepcopy,informer,lister \
    gitee.com/lovekernel/tiger/pkg/client gitee.com/lovekernel/tiger/api "apps:v1" -h ./hack/boilerplate.go.txt)

#rm -rf ./pkg/client/{clientset,informers,listers}
#mv "${TMP_DIR}"/src/gitee.com/lovekernel/tiger/pkg/client/* ./pkg/client

rm -rf vendor
